package top.yxf.spring.support;

import top.yxf.spring.BeansException;
import top.yxf.spring.config.BeanDefinition;

/**
 * @author xs.wu
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{


    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) throws BeansException {
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException|IllegalAccessException e) {
            throw new BeansException("InstantiationException of bean failed", e);
        }
        // 注册bean
        registerSingleton(beanName, bean);
        return bean;
    }
}
